package debtbundler.presentation.utils;

import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.Icon;
import javax.swing.ImageIcon;

/**
 * User interface library methods.
 * 
 * @author Anssi
 *
 */
public class UIUtils {
	
	private static Logger logger = Logger.getLogger(UIUtils.class.getName());
	
	/**
	 * Creates an empty 16x16 pixel icon.
	 * 
	 * @return	 an empty 16x16 pixel icon
	 */
	public static Icon getEmpty16x16Icon() {
		return EmptyIcon.SIZE_16;
	}
	
	/**
	 * Returns an icon created of the image identified by the
	 * given path.
	 * 
	 * @param path			the path of the image
	 * @return				an icon created of the image
	 * @throws RuntimeException
	 * 	if the specified image is not found
	 */
	public static ImageIcon getImageIcon(String path) {
		java.net.URL imgURL = UIUtils.class.getResource(path);
	    if (imgURL != null) {
	        return new ImageIcon(imgURL);
	    } else {
	    	logger.log(Level.SEVERE, "Could not find image {0}", path);
	        throw new RuntimeException("Could not find image " + path);
	    }

	}
	
}
